<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/8/3/003
 * Time: 16:17
 */
namespace App\Http\Controllers\Category;

use Illuminate\Http\Request;

use App\Http\Requests;
use App\Http\Service\Cate\CateService;
use App\Http\Controllers\Controller;
use Session,Config;
use Cache;

class CateController extends Controller
{

    public function cateView()
    {
        $cateinfo = $this->getCateList();

        return view('Category.category')->with('cateinfo',$cateinfo['data']);
    }


    /**
     * @param Request $request
     * @return mixed
     * 添加分类信息
     *
     */
    public function addCategory(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(Config::get('custom.setting.MEMBER_TOKEN'));
        $Cate = new CateService();

        $ret =  $Cate->addCupdateategory($where);

        return $ret;
    }

    /**
     * @param Request $request
     * @return bool|mixed|string
     * 修改分类
     */
    public function updateCate(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(Config::get('custom.setting.MEMBER_TOKEN'));
        $Cate = new CateService();

        $ret =  $Cate->updateCategory($where);
        return $ret;
    }

    /**
     * @param Request $request
     * @return mixed
     * 分类信息列表
     */
    public function getCateList()
    {

        $where['token'] = Session::get(Config::get('custom.setting.MEMBER_TOKEN'));

        $Cate = new CateService();
        $ret =  $Cate->getCategoryList($where);
        return $ret;

    }


    /**
     * @param Request $request
     * @return mixed
     * 添加关键词
     *
     */
    public function addKeyword(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(Config::get('custom.setting.MEMBER_TOKEN'));
        $Cate = new CateService();

        $ret =  $Cate->addKeyword($where);

        return $ret;
    }


    /**
     * @param Request $request
     * @return bool|mixed|string
     * 修改关键词
     */
    public function updateKeyword(Request $request)
    {
        $where = $request->except('_token');
        $where['token'] = Session::get(Config::get('custom.setting.MEMBER_TOKEN'));
        $Cate = new CateService();

        $ret =  $Cate->updateKeyword($where);
        return $ret;
    }

    /**
     * @param Request $request
     * @return mixed
     * 关键词列表
     */
    public function getKeywordList(Request $request)
    {

        $where = $request->except('_token');
        $where['token'] = Session::get(Config::get('custom.setting.MEMBER_TOKEN'));

        $Cate = new CateService();
        $ret =  $Cate->getKeywordList($where);
        return $ret;

    }

    /**
     * @param Request $request
     * @return mixed
     * 关键词列表
     */
    public function getKeywordListForeach()
    {

        $where['token'] = Session::get(Config::get('custom.setting.MEMBER_TOKEN'));

        $Cate = new CateService();
        $ret =  $Cate->getKeywordList($where);
        return $ret;

    }


}